import 'package:freezed_annotation/freezed_annotation.dart';
import 'dart:convert';

part 'user_my_goods_list_response.freezed.dart';
part 'user_my_goods_list_response.g.dart';

@freezed
class UserMyGoodsListResponse with _$UserMyGoodsListResponse {
  const factory UserMyGoodsListResponse({
    @JsonKey(name: "code") required int code,
    @JsonKey(name: "msg") required String msg,
    @JsonKey(name: "time") required int time,
    @JsonKey(name: "data") required Data data,
  }) = _UserMyGoodsListResponse;

  factory UserMyGoodsListResponse.fromJson(Map<String, dynamic> json) =>
      _$UserMyGoodsListResponseFromJson(json);
}

@freezed
class Data with _$Data {
  const factory Data({
    @JsonKey(name: "total") required int total,
    @JsonKey(name: "per_page") required int perPage,
    @JsonKey(name: "current_page") required int currentPage,
    @JsonKey(name: "last_page") required int lastPage,
    @JsonKey(name: "data") required List<Datum> data,
  }) = _Data;

  factory Data.fromJson(Map<String, dynamic> json) => _$DataFromJson(json);
}

@freezed
class Datum with _$Datum {
  const factory Datum({
    @JsonKey(name: "id") required int id,
    @JsonKey(name: "mainImage") required List<String> mainImage,
    @JsonKey(name: "date") required int date,
    @JsonKey(name: "userAvatar") required String userAvatar,
    @JsonKey(name: "userName") required String userName,
    @JsonKey(name: "dec") required String dec,
    @JsonKey(name: "content") required String content,
    @JsonKey(name: "collectionCount") required int collectionCount,
    @JsonKey(name: "commentCount") required int commentCount,
    @JsonKey(name: "likeCount") required int likeCount,
    @JsonKey(name: "viewUser") required ViewUser viewUser,
    @JsonKey(name: "label") required List<Label> label,
  }) = _Datum;

  factory Datum.fromJson(Map<String, dynamic> json) => _$DatumFromJson(json);
}

@freezed
class Label with _$Label {
  const factory Label({
    @JsonKey(name: "id") required int id,
    @JsonKey(name: "title") required String title,
    @JsonKey(name: "sort") required int sort,
    @JsonKey(name: "status") required int status,
    @JsonKey(name: "create_time") required int createTime,
    @JsonKey(name: "admin_id") required int adminId,
    @JsonKey(name: "image") required String image,
    @JsonKey(name: "jianjie") required String jianjie,
    @JsonKey(name: "goods_num") required int goodsNum,
  }) = _Label;

  factory Label.fromJson(Map<String, dynamic> json) => _$LabelFromJson(json);
}

@freezed
class ViewUser with _$ViewUser {
  const factory ViewUser({
    @JsonKey(name: "latestUserAvatar") required List<dynamic> latestUserAvatar,
    @JsonKey(name: "viewUserCount") required int viewUserCount,
  }) = _ViewUser;

  factory ViewUser.fromJson(Map<String, dynamic> json) =>
      _$ViewUserFromJson(json);
}
